Skip to content

test: Phase 3 — add sub-package tests for api/models (94.6%) and api/types (60.3%)#26

Open
AWaterColorPen wants to merge 1 commit into
mainfrom
feature/phase3-subpkg-coverage
Open

test: Phase 3 — add sub-package tests for api/models (94.6%) and api/types (60.3%)#26
AWaterColorPen wants to merge 1 commit into
mainfrom
feature/phase3-subpkg-coverage

Conversation

@AWaterColorPen
Copy link
Copy Markdown
Owner

Summary

This PR adds comprehensive unit tests for the api/models and api/types sub-packages, which previously had 0% test coverage.

Coverage Results

Package Before After
. (main) 82.8% 82.8%
api/models 0.0% 94.6%
api/types 0.0% 60.3%

Files Added

  • api/models/schema_test.go — 21 tests: Graph, DataSet, JoinPair, DimensionJoins, MergeJoin, DataSource, Dimension, Metric, GetNameFromKey
  • api/types/filter_test.go — Filter.Expression (all operators), tree AND/OR, error paths
  • api/types/column_test.go — SingleCol, ArithmeticCol, ExpressionCol
  • api/types/order_test.go — OrderBy.Expression/Statement/Alias
  • api/types/types_test.go — Dimension, Metric (all 10 types), Join, DataSource, TimeInterval/Query, Result

Notes

  • api/types remaining uncovered: clause.go (BuildSQL/BuildDB require gorm DB setup — integration tests, out of scope for unit tests)
  • All tests pass with go test ./...

Related: Phase 3 sub-package coverage boost (parallel to PR #25 deps upgrade)

…types (60.3%)

- api/models/schema_test.go: 21 tests covering Graph.GetTree, DataSet,
  JoinPair, DimensionJoins, MergeJoin, DataSource (IsFact/IsDimension/IsValid/
  GetDependencyTree/GetGetDependencyKey), DataSources, Dimension, Metric,
  GetNameFromKey
- api/types/filter_test.go: tests for FilterOperatorType.IsTree, Filter.Expression
  (all operator types), tree AND/OR, error paths, Statement, Alias, valueType auto-detect
- api/types/column_test.go: tests for SingleCol (Value/Count/DistinctCount/Sum/IfExpr),
  ArithmeticCol (Add/Subtract/Multiply/Divide/As), ExpressionCol
- api/types/order_test.go: tests for OrderBy.Expression/Statement/Alias
- api/types/types_test.go: tests for Dimension, Metric (all metric types),
  Join.GetJoinType, DataSource.Expression/Alias/Statement, TimeInterval/Query,
  Result.SetDimensions/AddSource

All 3 packages pass: main=82.8%, api/models=94.6%, api/types=60.3%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant